//给定两个正整数x和y，实现方法判断y是不是x的幂

function checkPower(y, x) {
    if (x <= 0 || y <= 0)
        return false
    if (y == 1)
        return true //0次幂
    if (x == 2)
        return (y & (y - 1)) == 0
    return isPower(y, x)
}

function isPower(y, x) {
    if (y == x)
        return true
    if (y % x != 0)
        return false
    return isPower(y / x, x)
}

console.log(checkPower(1024,2)) 
console.log(checkPower(100,2))
console.log(checkPower(Math.pow(3,31),3))
console.log(checkPower(30000,3))
console.log(checkPower(Math.pow(4,22),4))